package electricity.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import electricity.domain.SysUser;
import electricity.dto.SysUserWithRoleDto;
import electricity.dto.UserManageQueryDto;
import electricity.dto.UserUpdateDto;
import electricity.vo.UserManageQueryVO;
import electricity.vo.UserManageVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import java.util.List;

@Mapper
/**
* @author haoyi
* @description 针对表【sys_user】的数据库操作Mapper
* @createDate 2025-07-09 16:01:31
* @Entity generator.domain.SysUser
*/
public interface SysUserMapper extends BaseMapper<SysUser> {

    int deleteByPrimaryKey(Long id);

    int insert(SysUser record);

//    int insert(UserUpdateDto userUpdateDto);

    int insertSelective(SysUser record);

    SysUser selectByPrimaryKey(Integer id);

    SysUser selectByUsernameAndRole( @Param("username") String username,
                                     @Param("roleType") Integer roleType);
    int updateByPrimaryKeySelective(SysUser record);

    int updateByPrimaryKey(SysUser record);

//    int updateByPrimaryKey(UserUpdateDto userUpdateDto);

    List<SysUser> list();

    Page<UserManageQueryVO> pageQuery(UserManageQueryDto userManageQueryDto);

    SysUser selectByUsername(String username);

    Page<SysUser> selectUserPage(Page<SysUser> page,
                                     @Param("username") String username,
                                     @Param("realName") String realName,
                                     @Param("status") Integer status,
                                     @Param("roleName") String roleName);
    /**
     * 查询符合条件的用户总数
     * @param username 用户名（模糊搜索）
     * @param realName 姓名（模糊搜索）
     * @param status 用户状态
     * @param roleName 角色名称
     * @return 用户总数
     */
    int countUsersWithRoleByCondition(@Param("username") String username,
                                      @Param("realName") String realName,
                                      @Param("status") Integer status,
                                      @Param("roleName") String roleName);
}
